home *** CD-ROM | disk | FTP | other *** search
- Path: alterdial.uu.net!not-for-mail
- From: jim@dataware.com
- Newsgroups: comp.lang.c++
- Subject: VC++ 4: Templates and exported DLL functions
- Date: 16 Apr 1996 03:09:43 GMT
- Organization: Dataware Technologies, Inc.
- Message-ID: <4kv31n$ca6@alterdial.UU.NET>
- NNTP-Posting-Host: gw.dataware.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- There seems to be a logical hole in the way that Visual C++ uses a storage
- class-like extension to indicate that a class in a DLL is to be exported to
- clients of the DLL.
-
- For a non-template class, one simply inserts the extension keyword into the
- class definition:
-
- class __declspec(dllexport) AIntClass2
- {
- int AFunc();
- };
-
- int AIntClass2::AFunc(){return 0;}
-
- This results in the entire class being exported.
- I don't see how to accomplish the same thing with a template class. E.g.:
-
- template <class T>
- class AClass
- {
- T AFunc();
- };
-
- int AClass<int>::AFunc(){return 0;}
-
- The __declspec(dllexport) modifier cannot be added to the template declaration
- (syntax error). It can be added to AFunc(), but that only exports the single
- function, not the whole class. I tried using a typedef
-
- typedef AClass<int> __declspec(dllexport) AClassInt1;
-
- but since the __declspec(dllexport) is a storage modifier, it is not
- considered part of the type and so uses of the typedef tag are not exported.
-
- Is there a solution I'm missing here? (aside from listing every identifier
- explicitly in a .DEF file)?
-
-